The way an #include
directive finds an actual file is implementation-defined, and in practice, it slightly differs in different
systems.
Therefore, a good practice is to identify the files to include in the most straightforward way possible to reduce the risk of inconsistent
behaviors.
This rule raises an issue when:
- The case of the file in the
#include
directive does not match the case of the file on the disk (the inclusion would not work on a
case-sensitive OS),
- The file name in the
#include
directive contains trailing spaces (they would be ignored on Windows but considered on Unix).
Noncompliant code example
#include "Foo.h" // Noncompliant if the actual file name is "foo.h"
#include "bar.h " // Noncompliant, trailing space